<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./js/vue.js"></script>
    <div id='app'>
        {{val}}
        {{obj.name}}
        {{obj.value}}
    </div>
    
    <script>
        let app =new Vue({
             el:"#app",
             data:{
                val:'简单对象初始值',
                obj:{
                    name:'复杂对象name',
                    value:'复杂对象value'
                }
             },
             watch:{
                val:function(newval,oldval){//每当值改变就可以在控制台中看到新值与旧值对比
                    console.log(newval,oldval);
                    console.log(this.val);
                },
                obj:{
                    deep:true,//复杂对象的监听方式需要设置参数deep=true
                    handler:function(new_val,old_val){
                        console.log(new_val,old_val);
                    }
                }
             }
        })
    </script>
</body>
</html>